a = input()
k= []
for i in a:
    if i == '(' or i == '{' or i == '[' or i =='<':
        k.append(i)
    elif i == ')':
        if len(k) > 0:
            if k[-1] == '(':
                del k[-1]
            else:
                print('False')
                raise SystemExit
        else:
            print('False')
            raise SystemExit
    elif i == '}':
        if len(k) > 0:
            if k[-1] == '{':
                del k[-1]
            else:
                print('False')
                raise SystemExit
        else:
            print('False')
            raise SystemExit
    elif i == ']':
        if len(k) > 0:
            if k[-1] == '[':
                del k[-1]
            else:
                print('False')
                raise SystemExit
        else:
            print('False')
            raise SystemExit
    elif i == '>':
        if len(k) > 0:
            if k[-1] == '<':
                del k[-1]
            else:
                print('False')
                raise SystemExit
        else:
            print('False')
            raise SystemExit    
if len(k) > 0:
    print('False')
else:
    print('True')